home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / surface_fit.pro < prev    next >
Text File  |  1997-07-08  |  2KB  |  94 lines

  1. ; $Id: surface_fit.pro,v 1.2 1993/07/26 16:23:39 Moglie Exp $
  2.  
  3. FUNCTION SURFACE_FIT, surface,degree
  4. ;+
  5. ; NAME:
  6. ;    SURFACE_FIT
  7. ;
  8. ; PURPOSE:
  9. ;    Determine a polynomial fit to a surface.
  10. ;
  11. ;    This function uses POLYWARP to determine the coefficients of the 
  12. ;    polynomial, then evaluates the polynomial to yield the fit surface. 
  13. ;
  14. ; CATEGORY:
  15. ;    E2 - Curve and surface fitting.
  16. ;
  17. ; CALLING SEQUENCE:
  18. ;    Result = SURFACE_FIT(Data_Surface, Degree)
  19. ;
  20. ; INPUTS:
  21. ; Data_Surface:    The two-dimensional array of data to be fit to.  The sizes of
  22. ;        each dimension may be unequal.
  23. ;
  24. ;    Degree:    The maximum degree of fit (in one dimension).
  25. ;
  26. ; OPTIONAL INPUT PARAMETERS:
  27. ;    None.
  28. ;
  29. ; OUTPUTS:
  30. ;    SURFACE_FIT returns a two-dimensional array of values from the 
  31. ;    evaluation of the polynomial fit.
  32. ;
  33. ; COMMON BLOCKS:
  34. ;    None.
  35. ;
  36. ; SIDE EFFECTS:
  37. ;    None.
  38. ;
  39. ; RESTRICTIONS:
  40. ;    The number of data points in data_surface must be greater or equal to
  41. ;    (Degree+1)^2.
  42. ;
  43. ; PROCEDURE:
  44. ;    Generate coordinate arrays for POLYWARP using the indices as
  45. ;    coordinates.  The yi and ky arrays for POLYWARP are, in this usage,
  46. ;    redundant, so they are sent as dummies.  The coefficients returned
  47. ;    from POLYWARP are then used in evaluating the polynomial fit to give
  48. ;    the surface fit.
  49. ;
  50. ; MODIFICATION HISTORY:
  51. ;    Written by:  Leonard Sitongia, LASP, University of Colorado,
  52. ;             April, 1984.
  53. ;
  54. ;    Modified by: Mike Jone, LASP, Sept. 1985.
  55. ;    July 1993:    JIY, RSI: became obsolete; use SFIT function
  56. ;
  57. ;-
  58. ;
  59. ;                sizes of dimensions of surface
  60. ;
  61.     on_error,2                      ;Return to caller if an error occurs
  62.  
  63.     PRINT, 'This routine is obsolete.  Please use SFIT instead."
  64.  
  65.     sizes = SIZE (surface)
  66.     size_x = sizes (1)
  67.     size_y = sizes (2)
  68. ;
  69. ;                initialize
  70. ;
  71.     coord_x = indgen(size_x, size_y) mod size_x    ;X coords.
  72.     coord_y = indgen(size_x, size_y) / size_x    ; & y.
  73.     fit     = FLTARR (size_x,size_y)
  74.     re_surf = FLTARR (size_x,size_y)
  75. ;
  76. ;                compute fit coefficients
  77. ;
  78.     POLYWARP, surface,re_surf,coord_x,coord_y,degree,coef,re_coef
  79.     coef = TRANSPOSE (coef)
  80. ;
  81. ;                compute fit surface from coefficients
  82. ;
  83.     fit = fit + coef(0,0)        ;constant term.
  84.     FOR ix = 1,degree DO fit = fit + coef (ix,0)*coord_x^ix
  85.     FOR iy = 1,degree DO fit = fit + coef (0,iy)*coord_y^iy
  86.     FOR ix = 1,degree DO $
  87.         FOR iy = 1,degree DO $
  88.             fit = fit + coef (ix,iy)*coord_x^ix*coord_y^iy
  89. ;
  90. ;                return fit surface
  91. ;
  92.     RETURN, fit
  93.     END
  94.